package com.learn.image.utils;

import com.learn.image.enums.ReturnCodeAndMsgEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * 统一web返回结果
 * @author: Administrator
 * @createTime: 2023/11/28 0028 18:10
 * @version: 1.0
 */
@Data
public class R<T> implements Serializable {


    private static final long serialVersionUID = -7625361627980115178L;
    private int code;

    private String msg;

    private T data;

    public R(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public R(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(ReturnCodeAndMsgEnum codeAndMsgEnum) {
        this(codeAndMsgEnum.getCode(), codeAndMsgEnum.getName(),null);
    }
    public R(ReturnCodeAndMsgEnum codeAndMsgEnum,T data) {
        this(codeAndMsgEnum.getCode(), codeAndMsgEnum.getName(),data);
    }


    public R(T data) {
        this(ReturnCodeAndMsgEnum.SUCCESS,data);
    }

}
